import json


class PlayerInfo:
    def __init__(self, iname, iage):
        self.info_name = iname
        self.info_age = iage

    def __dict__(self):
        return {'name': self.info_name, 'age': self.info_age}

    def to_dic(self):
        return {'name':self.info_name, 'age':self.info_age}


def test():
    players = []
    player1 = PlayerInfo('demo1', 30)
    player2 = PlayerInfo('demo2', 20)
    players.append(player1)
    players.append(player2)
    json_data = json.dumps(player1.to_dic()) + json.dumps(player2.to_dic())
    print(json_data)


if __name__ == '__main__':
    test()
